package com.yao2san.simdif.enums;

import lombok.Getter;

import java.util.Objects;

public enum CommonStatus {
    OK(0, "正常"),
    DELETED(-1, "已删除"),
    ;
    @Getter
    private final int code;
    @Getter
    private final String name;

    CommonStatus(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static CommonStatus of(int code) {
        for (CommonStatus value : CommonStatus.values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        throw new IllegalArgumentException("不持支的状态");
    }
}
